#! /bin/sh

# Additional options that are passed to Spotify server
OPTIONS=""

case "$1" in
    start)
	printf "Starting spotifyd: "
	start-stop-daemon -S --background -q --exec /opt/hifiberry/bin/spotify-watchdog $OPTIONS
	[ $? = 0 ] && echo "OK" || echo "FAIL"
	;;
    stop)
	printf "Stopping spotifyd: "
	start-stop-daemon -K -x /opt/hifiberry/bin/spotify-watchdog
	[ $? = 0 ] && echo "OK" || echo "FAIL"
;;
    restart)
	$0 stop
	$0 start
	;;
    *)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
	;;
esac

